<template>
      <div>
        账号：<input  type="text" v-model="account" placeholder="请输入账号"/><br/>
        密码：<input  type="text" v-model="password" placeholder="请输入密码"/><br/>
        <button @click="submit">登录</button>
      </div>
      <div>
      
      </div>
</template>

<script setup>
 import { ref } from "vue";
 //引入路由
 import  { useRouter } from 'vue-router'
//引入Vuex
import { useStore } from "vuex"


 const account =ref('')
 const password = ref('')

 //获取路由的实例化对象
 const router = useRouter()

 //获取Vuex的实例化对象
 const store = useStore()

const submit = ()=>{
    if (account.value=='admin' && password.value=='123456') {
        //保存用户信息
        store.commit("updatauserInfo",{
             name:'王老板',
             gender:'男',
             age:'55',
             phone:'1777',
        })
        //跳转到个人中心页
        router.push({path:'/user'})
    }
    else{
        alert("账号或密码错误，请重新输入！")
    }
}

  </script>